package com.wocao.controller;

import com.wocao.entity.ResponseResult;
import com.wocao.entity.SysArea;
import com.wocao.service.SysAreaService;
import com.wocao.utils.Tree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/sysArea")
public class SysAreaController {
    @Autowired
    private SysAreaService sysAreaService;

    @GetMapping("selectAreaAllTree")
    public ResponseResult selectAreaAllTree(){
        List<SysArea> sysAreas = Tree.areaTree(sysAreaService.list());
        return ResponseResult.ok(sysAreas);
    }
}
